package org.regotto.basics.graph;

import org.regotto.common.Utils;

import java.util.Scanner;

/**
 * 拓扑排序
 * 判断一个图是否满足拓扑排序
 */
public class TopologicalSorting {

    static final int N = 1000;
    static int[] h = new int[N], e = new int[N], ne = new int[N], q = new int[N], d = new int[N];
    static int n, m, idx;

    static void add(int a, int b) {
        e[idx] = b; ne[idx] = h[a]; h[a] = idx++;
    }

    static boolean ts() {
        int hh = 0, tt = -1;
        for (int i = 1; i <= n; i++) {
            if (d[i] == 0) q[++tt] = i;
        }
        while (hh <= tt) {
            int t = q[hh++];
            for (int i = h[t]; i != -1; i = ne[i]) {
                int j = e[i];
                d[j]--;
                if (d[j] == 0) q[++tt] = j;
            }
        }
        return tt == n - 1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        Utils.full(h, -1);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            add(a, b);
            d[b]++;
        }
        if (ts()) Utils.printInts(q);
        else System.out.println(-1);
    }

}
